package com.myjoje.config.shiro;

import com.myjoje.bean.UserBean;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.SimpleHash;

public class ShiroUtil {

    public static String getMd5(String content) {
        return new SimpleHash("md5", content).toString();
    }

    public static String getSha1(String content) {
        return new SimpleHash("SHA-1", content).toString();
    }

    public static UserBean getCurrentUser() {
        UserBean bean = (UserBean) SecurityUtils.getSubject().getPrincipal();
        bean.setPassword(null);
        return bean;
    }

    public static boolean hasRole(String role) {

        return SecurityUtils.getSubject().hasRole(role);
    }
}

